package com.jzo2o.foundations.controller.operation;


import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
@Api(tags = "运营端-区域服务相关接口")
@RestController("operationServeController")
@RequestMapping("/operation/serve")
public class ServeController {

    @Resource
    private IServeService serveService;

    @GetMapping("page")
    @ApiOperation("区域服务分页查询")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO servePageQueryReqDTO){
        return serveService.page(servePageQueryReqDTO);
    }


    @PostMapping("/batch")
    @ApiOperation("批量新增区域服务")
    public void batch(@RequestBody List<ServeUpsertReqDTO> serveUpsertReqDTOs){
        serveService.batchInsert(serveUpsertReqDTOs);
    }

    @PutMapping("/{id}")
    @ApiOperation("区域服务价格修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务id", required = true, dataTypeClass = Long.class),
            @ApiImplicitParam(name = "price", value = "价格", required = true, dataTypeClass = BigDecimal.class)
    })
    public void updatePriceById(@PathVariable("id") Long id,@RequestParam("price") BigDecimal price){
        serveService.updatePriceById(id,price);
    }

    @PutMapping("/onSale/{id}")
    @ApiOperation("区域服务上架")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "服务id",required = true,dataTypeClass = List.class)
    })
    public void onSaleServe(@PathVariable("id") Long id){
        serveService.onSale(id);


    }


    @DeleteMapping("/{id}")
    @ApiOperation("删除区域服务")
    public void delete(@PathVariable("id") Long id){
        serveService.deleteServe(id);
    }


    @PutMapping("/offSale/{id}")
    @ApiOperation("服务下架")
    public void offSaleServe(@PathVariable("id") Long id){
        serveService.offSale(id);
    }

    @PutMapping("/onHot/{id}")
    @ApiOperation("设置热门服务")
    public void onHotServe(@PathVariable("id") Long id){
        serveService.onHot(id);
    }

    @PutMapping("/offHot/{id}")
    @ApiOperation("取消热门服务")
    public void offHotServe(@PathVariable("id") Long id){
        serveService.offHot(id);
    }



}
